﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JVMTI_CONN_CONNECT
{
    public class JvmtiEventCreationOptions
    {
        //public const string Object = "Object";
        //public const string MethodName = "MethodName";
        //public const string Timestamp = "Timestamp";
        //public const string StackTrace = "StackTrace";
        //public const string NameAssignment = "NameAssignment";
        internal dynamic ConvertToStrongType(JvmtiMethodEnum type, int argumentIndex, string argumentInStr, string fileInuse, out string identifier)
        {
            switch (argumentIndex)
            {
                case 0:
                    identifier = "Timestamp";
                    return double.Parse(argumentInStr);
                case 1:
                    identifier = "MethodName";
                    return type;
                case 2:
                    identifier = "SubjectThread";
                    return argumentInStr;
                case 3:
                    switch (type)
                    {
                        case JvmtiMethodEnum.ThreadStart:
                        case JvmtiMethodEnum.MonitorContendedEnter:
                        case JvmtiMethodEnum.MonitorContendedEntered:
                        case JvmtiMethodEnum.ObjectWait:
                        case JvmtiMethodEnum.ObjectWaited:
                        case JvmtiMethodEnum.ObjectNotify:
                        case JvmtiMethodEnum.SemaphoreAcquired:
                        case JvmtiMethodEnum.SemaphoreReleased:
                        case JvmtiMethodEnum.SemaphoreAcquire:
                        case JvmtiMethodEnum.SemaphoreRelease:
                            identifier = "Object";
                            return argumentInStr;
                        case JvmtiMethodEnum.ThreadSlept:
                        case JvmtiMethodEnum.ThreadSleep:
                            identifier = "StackTrace";
                            return new StackTrace(argumentInStr, fileInuse);
                        case JvmtiMethodEnum.ThreadStarted:
                            identifier = "NameAssignment";
                            return argumentInStr;
                    }
                    break;
                case 4:
                    switch (type)
                    {
                        case JvmtiMethodEnum.ObjectWait:
                        case JvmtiMethodEnum.ObjectWaited:
                        case JvmtiMethodEnum.ObjectNotify:
                        case JvmtiMethodEnum.ObjectNotifyAll:
                        case JvmtiMethodEnum.ThreadStart:
                        case JvmtiMethodEnum.ThreadJoin:
                        case JvmtiMethodEnum.ThreadJoined:
                        case JvmtiMethodEnum.MonitorContendedEntered:
                        case JvmtiMethodEnum.SemaphoreAcquired:
                        case JvmtiMethodEnum.SemaphoreReleased:
                        case JvmtiMethodEnum.SemaphoreRelease:
                        case JvmtiMethodEnum.SemaphoreAcquire:
                            identifier = "StackTrace";
                            return new StackTrace(argumentInStr, fileInuse);
                        case JvmtiMethodEnum.MonitorContendedEnter:
                            identifier = "OwnerThread";
                            return argumentInStr;
                    }
                    break;
                case 5:
                    switch (type)
                    {
                        case JvmtiMethodEnum.MonitorContendedEnter:
                            identifier = "Stacktrace";
                            return new StackTrace(argumentInStr, fileInuse);
                    }
                    break;
            }
            identifier = "Not Implemented";
            return "Not Implemented";
        }

        public JvmtiEventCreationOptions(string classTable)
        {

        }
    }
}
